package jianzhi

import "strings"

/*
	Fields splits the string s around each instance of one or more
	consecutive white space characters, as defined by unicode.IsSpace,
	returning a slice of substrings of s or an empty slice
	if s contains only white space.
*/

func reverseWords(s string) string {
	wordlist := strings.Fields(s)

	for i := 0; i < len(wordlist)/2; i++ {
		wordlist[i], wordlist[len(wordlist)-1-i] = wordlist[len(wordlist)-1-i], wordlist[i]
	}

	res := strings.Join(wordlist, " ")

	return res

}
